﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <input type="hidden" id="id" name="id" />
        <div class="form-group">
            <label class="col-sm-3 control-label ">上级部门</label>
            <div class="col-sm-8">
                <div id="parentId" name="parentId"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">部门名称<font class="red"> *</font></label>
            <div class="col-sm-8">
                <input id="departmentName" autocomplete="off" name="departmentName" type="text" class="form-control" />
            </div>
        </div>
        @*<div class="form-group">
            <label class="col-sm-3 control-label ">负责人</label>
            <div class="col-sm-8">
                <div id="principalId" name="principalId"></div>
            </div>
        </div>*@
        <div class="form-group">
            <label class="col-sm-3 control-label ">电话号码</label>
            <div class="col-sm-8">
                <input id="telephone" autocomplete="off" name="telephone" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">传真</label>
            <div class="col-sm-8">
                <input id="fax" name="fax" autocomplete="off" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">Email</label>
            <div class="col-sm-8">
                <input id="email" name="email" autocomplete="off" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">显示顺序</label>
            <div class="col-sm-8">
                <input id="departmentSort" name="DepartmentSort" autocomplete="off" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">备注</label>
            <div class="col-sm-8">
                <textarea id="remark" name="remark" autocomplete="off" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        //获取部门信息
        $('#parentId').ysComboBoxTree({
            url: '/OrganizationManage/Department/GetDepartmentTreeListJson', async: false
        });
        //获取部门人员
        //$('#principalId').ysComboBoxTree({
        //    url: '/OrganizationManage/Department/GetUserTreeListJson', async: false
        //});
        getForm();
        $("#form").validate({
            rules: {
                departmentName: { required: true },
                parentIdInput: { required: true }
            }
        });
    });
    function getForm() {
       //修改赋值使用
        var editData = storage.get("editData");
        if (editData != null && editData.length > 0) {
            //表单赋值
            $("#form").setWebControls(JSON.parse(editData));
        }
    }
    /***提交数据***/
    function submitForm() {
        if ($("#form").validate().form()) {
            $.operate.save("/OrganizationManage/Department/SaveFormJson", $('#form').getWebControls());
        }
    }
</script>
